package wwwContinent;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class ServletDemo01 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //全局对象，Tomcat启动时就创建好的所有类共享的对象
        ServletContext servletContext = getServletContext();
        System.out.println(servletContext.getInitParameter("数码宝贝"));
        servletContext.setAttribute("sweetheart", "八神嘉儿");
        List<String> 被选召的孩子 = Arrays.asList("八神太一", "石田大和", "武之内素娜", "泉光子郎",
                "太刀川美美", "城户助", "高石武", "八神嘉儿");
        servletContext.setAttribute("被选召的孩子", 被选召的孩子);
        servletContext.setAttribute("city", "心上人");
        //servletContext.setInitParameter("city","御台场");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
